
package com.engagesoft.cashflow.entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author rchajin
 */
@Entity
@Table(name = "documento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Documento.findAll", query = "SELECT d FROM Documento d ORDER BY d.idDocumento DESC"),
    @NamedQuery(name = "Documento.findByTipoDocumento", query = "SELECT d FROM Documento d WHERE d.idTipoDocumento = :idTipoDocumento ORDER BY d.idDocumento DESC"),
    @NamedQuery(name = "Documento.findByIdDocumento", query = "SELECT d FROM Documento d WHERE d.idDocumento = :idDocumento"),
    @NamedQuery(name = "Documento.findByFecDoc", query = "SELECT d FROM Documento d WHERE d.fecDoc = :fecDoc"),
    @NamedQuery(name = "Documento.findByValorDoc", query = "SELECT d FROM Documento d WHERE d.valorDoc = :valorDoc"),
    @NamedQuery(name = "Documento.findByAnuladoDoc", query = "SELECT d FROM Documento d WHERE d.anuladoDoc = :anuladoDoc"),
    @NamedQuery(name = "Documento.findByNotaDoc", query = "SELECT d FROM Documento d WHERE d.notaDoc = :notaDoc"),
    @NamedQuery(name = "Documento.findByConsecutivoDoc", query = "SELECT d FROM Documento d WHERE d.consecutivoDoc = :consecutivoDoc")})
public class Documento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_documento")
    private Integer idDocumento;
    @Column(name = "fec_doc")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecDoc;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "valor_doc")
    private Double valorDoc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "anulado_doc")
    private boolean anuladoDoc;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "nota_doc")
    private String notaDoc;
    @Column(name = "consecutivo_doc")
    private Integer consecutivoDoc;
    @JoinColumn(name = "id_tipo_documento", referencedColumnName = "id_tipo_documento")
    @ManyToOne
    private TipoDocumento idTipoDocumento;
    @JoinColumn(name = "id_cliente", referencedColumnName = "id_cliente")
    @ManyToOne
    private Cliente idCliente;
    @JoinColumn(name = "id_tipo_dinero", referencedColumnName = "id_tipo_dinero")
    @ManyToOne
    private TipoDinero idTipoDinero;
    @OneToMany(mappedBy = "idDocumento")
    private Collection<MovimientoDocumento> movimientoDocumentoCollection;

    public Documento() {
    }

    public Documento(Integer idDocumento) {
        this.idDocumento = idDocumento;
    }

    public Documento(Integer idDocumento, boolean anuladoDoc, String notaDoc) {
        this.idDocumento = idDocumento;
        this.anuladoDoc = anuladoDoc;
        this.notaDoc = notaDoc;
    }

    public Integer getIdDocumento() {
        return idDocumento;
    }

    public void setIdDocumento(Integer idDocumento) {
        this.idDocumento = idDocumento;
    }

    public Date getFecDoc() {
        return fecDoc;
    }

    public void setFecDoc(Date fecDoc) {
        this.fecDoc = fecDoc;
    }

    public Double getValorDoc() {
        return valorDoc;
    }

    public void setValorDoc(Double valorDoc) {
        this.valorDoc = valorDoc;
    }

    public boolean getAnuladoDoc() {
        return anuladoDoc;
    }

    public void setAnuladoDoc(boolean anuladoDoc) {
        this.anuladoDoc = anuladoDoc;
    }

    public String getNotaDoc() {
        return notaDoc;
    }

    public void setNotaDoc(String notaDoc) {
        this.notaDoc = notaDoc;
    }

    public Integer getConsecutivoDoc() {
        return consecutivoDoc;
    }

    public void setConsecutivoDoc(Integer consecutivoDoc) {
        this.consecutivoDoc = consecutivoDoc;
    }

    public TipoDocumento getIdTipoDocumento() {
        return idTipoDocumento;
    }

    public void setIdTipoDocumento(TipoDocumento idTipoDocumento) {
        this.idTipoDocumento = idTipoDocumento;
    }

    public Cliente getIdCliente() {
        return idCliente;
    }

    public void setIdCliente(Cliente idCliente) {
        this.idCliente = idCliente;
    }

    public TipoDinero getIdTipoDinero() {
        return idTipoDinero;
    }

    public void setIdTipoDinero(TipoDinero idTipoDinero) {
        this.idTipoDinero = idTipoDinero;
    }

    @XmlTransient
    public Collection<MovimientoDocumento> getMovimientoDocumentoCollection() {
        return movimientoDocumentoCollection;
    }

    public void setMovimientoDocumentoCollection(Collection<MovimientoDocumento> movimientoDocumentoCollection) {
        this.movimientoDocumentoCollection = movimientoDocumentoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDocumento != null ? idDocumento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Documento)) {
            return false;
        }
        Documento other = (Documento) object;
        if ((this.idDocumento == null && other.idDocumento != null) || (this.idDocumento != null && !this.idDocumento.equals(other.idDocumento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.engagesoft.cashflow.entidades.Documento[ idDocumento=" + idDocumento + " ]";
    }
    
}
